﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Autocentro.Entities;


namespace Autocentro.Respository.Mapping
{
    public class VehiculoMap:EntityTypeConfiguration<VEHICULO>
    {
        public VehiculoMap()
        {
            this.HasKey(v =>v.Id);

            this.Property(v => v.NumSerieMotor)
                .IsOptional()
                .HasMaxLength(40);

           

            this.Property(v => v.Chasis)
                .IsOptional()
                .HasMaxLength(40);

            this.Property(v => v.ModeloVehiculo)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(v => v.Placa)
                .IsRequired()
                .HasMaxLength(10);

            this.ToTable("VEHICULO");
            this.Property(c => c.Id).HasColumnName("Id");
            this.Property(c => c.NumSerieMotor).HasColumnName("NroMotor");
            this.Property(c => c.Placa).HasColumnName("Placa");

            //Relaciones
            this.HasRequired(c => c.Marca)
                .WithMany(c => c.VEHICULOs)
                .HasForeignKey(c => c.IdMarca);

            this.HasRequired(c => c.Cliente)
                .WithMany(c => c.VEHICULOs)
                .HasForeignKey(c => c.IdCliente);

        }
    }
}
